<!--  -->
<template>
  <div class="column-detail-page w-75 mx-auto">
    <div class="column-info row mb-4 border-bottom pb-4 align-items-center">
      <div class="col-3 text-center" v-if="column?.avatar">
        <img :src="column?.avatar.url" :alt="column?.title" class="rounded-circle">
      </div>
      <div :class="{ 'col-9': column?.avatar }">
        <h4>{{column?.title}}</h4>
        <p class="text-muted">{{column?.description}}</p>
      </div>
    </div>
    <PostList :list="list"></PostList>
  </div>
</template>

<script lang="ts">
import { ColumnProps, PostProps, testData, testPosts } from '@/hooks/testData'
import { defineComponent, PropType, computed, onMounted, onBeforeMount } from 'vue'
import { useRoute } from "vue-router"
import PostList from "../components/PostList.vue"
import { useStore } from 'vuex'
export default defineComponent({
    name: "ColumnDetail",
    setup() {
        const route = useRoute()
        const store = useStore()
        const currentId = route.params.id
        const column = computed(() => store.getters.getColumnById(currentId))
        const list = computed(() => store.getters.getPostsByCid(currentId))

        onBeforeMount(() => {
          store.dispatch('getColumnDetail', currentId)
        })
        return {
          column,
          list
        }
    },
    components: { PostList }
})
</script>

<style  scoped lang='less'>

</style>
